$(function() {

    // Language menu hover
    $('#topnav li, #topnav li a').hoverIntent(
            function() {
                $(this).children('ul').fadeIn('fast');
            },
            function() {
                $(this).children('ul').fadeOut('fast');
            }
    );

    $('.sf-menu').superfish();

    subscribe_submit = function() {

        $('#subscribe_form button').attr('disabled', 'disabled');

        $("#subscribe").mask(API.Data.lang['dtl_subscribing'] + "...");


        form = $('#subscribe_form');
        var serialize = form.serialize();

        $.ajax({
            url: API.Data.lang_url + '/subscribe?' + serialize + '&ajax=true',
            method: 'get',
            success: function(data) {
                $("#subscribe").unmask();

                if (data == 0) {
                    alert(API.Data.lang['dtl_subscribe_alredy']);
                    $('#subscribe_form button').removeAttr('disabled');

                } else {
                    alert(API.Data.lang['dtl_subscribe_thanks']);

                }

            }
        });
    };

    $('#subscribe_form').validate({
        errorElement: "em",
        submitHandler: subscribe_submit
    });


    $('.maxps').tooltip({
        track: true,
        show: {duration: 800},
        hide: {duration: 100}
    });


});